//1122. 数组的相对排序
//思路：哈希表的使用，也是计数排序

int* relativeSortArray(int* arr1, int arr1Size, int* arr2, int arr2Size, int* returnSize){
    *returnSize = arr1Size;
    int hash[1001] = {0};
    int index = 0;
    for(int i = 0; i < arr1Size; i++)
    {
         hash[arr1[i]]++;
    }
    
    for(int i = 0; i < arr2Size; i++)
    {
        while(hash[arr2[i]])
        {
            arr1[index++] = arr2[i];
            hash[arr2[i]]--;
        }
    }

    for(int i = 0; i < 1001; i++)
    {
        while(hash[i])
        {
            arr1[index++] = i;
            hash[i]--;
        }
    }
    return arr1;
}